package com.example.pay_service.controller;

import com.example.pay_service.return_data.Mall_Data;
import com.example.pay_service.service.CardService;
import com.example.pay_service.vo.Card;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @title: CardController
 * @projectName mall
 * @description: TODO
 * @author TLJ
 * @date 2021/12/916:53
 */

@RestController
@RequestMapping("pay")
public class CardController {
    @Autowired
    CardService service;

    @RequestMapping("showcard")
    public Mall_Data showcard(@RequestParam("user_id") int user_id){
        List<Card> list  = service.showcar(user_id);
        if (list.size()>0){
            Mall_Data mall = new Mall_Data();
            mall.setcode(1);
            mall.seterror("查询成功");
            mall.setdata(list);
            return mall;
        }
        Mall_Data mall = new Mall_Data();
        mall.setcode(0);
        mall.seterror("没有该用户或该用户还未添加银行卡");
        mall.setdata("");
        return mall;
    }
}
